package liuwanghui.dto;

import lombok.Data;
import java.math.BigDecimal;

@Data
public class PurchaseDTO {
    private Long productId;
    private Long farmerId;
    private Integer quantity;
    private BigDecimal price;
    private String remarks;

    // 手动验证方法
    public String validate() {
        if (productId == null) {
            return "商品ID不能为空";
        }
        if (farmerId == null) {
            return "农户ID不能为空";
        }
        if (quantity == null || quantity < 1) {
            return "数量必须大于0";
        }
        if (price == null || price.compareTo(new BigDecimal("0.01")) < 0) {
            return "单价必须大于0";
        }
        return null;
    }
}